var e = getApp(), t = require("../../339469457B99569C55F201426D89DBD0.js"), o = require("../../38034BA77B99569C5E6523A090A9DBD0.js"), a = t.getImgCheckurl(), i = t.getFacedecorationurl();

Page({
    data: {
        motto: "腾讯优图",
        images: {},
        img: "",
        remark: "",
        model: 0,
        tempFilePaths: "",
        userInfo: {},
        backUserInfo: {},
        hasUserInfo: !1,
        openId: "",
        nickName: "",
        token: null,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        facemergeData: [ {
            id: "1",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/1.jpg",
            text: "埃及妆"
        }, {
            id: "2",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/2.jpg",
            text: "巴西土著妆"
        }, {
            id: "3",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/3.jpg",
            text: "灰姑娘妆"
        }, {
            id: "4",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/4.jpg",
            text: "恶魔妆"
        }, {
            id: "5",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/5.jpg",
            text: "武媚娘妆"
        }, {
            id: "6",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/6.jpg",
            text: "星光薰衣草"
        }, {
            id: "7",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/7.jpg",
            text: "花千骨"
        }, {
            id: "8",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/8.jpg",
            text: "僵尸妆"
        }, {
            id: "9",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/9.jpg",
            text: "爱国妆"
        }, {
            id: "10",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/10.jpg",
            text: "小胡子妆"
        }, {
            id: "11",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/11.jpg",
            text: "美羊羊妆"
        }, {
            id: "12",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/12.jpg",
            text: "火影鸣人妆"
        }, {
            id: "13",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/13.jpg",
            text: "刀马旦妆"
        }, {
            id: "14",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/14.jpg",
            text: "泡泡妆"
        }, {
            id: "15",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/15.jpg",
            text: "桃花妆"
        }, {
            id: "16",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/16.jpg",
            text: "女皇妆"
        }, {
            id: "17",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/17.jpg",
            text: "权志龙"
        }, {
            id: "18",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/18.jpg",
            text: "撩妹妆"
        }, {
            id: "19",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/19.jpg",
            text: "印第安妆"
        }, {
            id: "20",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/20.jpg",
            text: "印度妆"
        }, {
            id: "21",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/21.jpg",
            text: "萌兔妆"
        }, {
            id: "22",
            url: "https://wximage-1251091977.cos.ap-beijing.myqcloud.com/facedecoration/22.jpg",
            text: "大圣妆"
        } ]
    },
    onShareAppMessage: function() {
        return {
            title: "一键变妆",
            path: "/pages/facedecoration/facedecoration",
            success: function(e) {
                "shareAppMessage:ok" == e.errMsg && wx.showToast({
                    title: "分享成功",
                    icon: "success",
                    duration: 500
                });
            },
            fail: function(e) {
                "shareAppMessage:fail cancel" == e.errMsg && wx.showToast({
                    title: "分享取消",
                    icon: "loading",
                    duration: 500
                });
            }
        };
    },
    bindViewTap: function() {
        wx.navigateTo({
            url: "../logs/logs"
        });
    },
    onFaceMerge: function(e) {
        var t = this;
        console.log(t);
        var o = e.currentTarget.dataset.id;
        t.data.tempFilePaths ? (t.setData({
            model: o
        }), setTimeout(function() {
            wx.showLoading({
                title: "智能处理中",
                mask: !0
            });
        }, 500), wx.uploadFile({
            url: a,
            filePath: e.tempFilePaths[0],
            header: {
                "content-type": "multipart/form-data"
            },
            name: "file",
            formData: {
                code: "XSYD"
            },
            success: function(e) {
                var a = JSON.parse(e.data);
                "0" == a.errcode ? wx.uploadFile({
                    url: i,
                    filePath: t.data.tempFilePaths[0],
                    header: {
                        "content-type": "multipart/form-data"
                    },
                    name: "file",
                    formData: {
                        model: o
                    },
                    success: function(e) {
                        var o = e.data, a = JSON.parse(o);
                        console.log(a.ret), 0 == a.ret ? t.setData({
                            img: "data:image/png;base64," + a.data.image
                        }) : 16402 == a.ret ? wx.showModal({
                            title: "温馨提示",
                            content: "图片中不包含人脸哦",
                            showCancel: !1
                        }) : wx.showModal({
                            title: "温馨提示",
                            content: "服务器远走高飞了",
                            showCancel: !1
                        }), wx.hideToast();
                    },
                    fail: function(e) {
                        wx.hideToast(), wx.hideLoading(), wx.showModal({
                            title: "上传失败",
                            content: "服务器远走高飞了",
                            showCancel: !1
                        });
                    }
                }) : "87014" == a.errcode ? (wx.hideLoading(), wx.showModal({
                    content: "存在敏感内容，请更换图片",
                    showCancel: !1,
                    confirmText: "明白了"
                }), t.setData({
                    img: null
                })) : (wx.hideLoading(), wx.showModal({
                    content: "其他错误，稍后再试",
                    showCancel: !1,
                    confirmText: "明白了"
                }));
            }
        })) : wx.showToast({
            title: "快选择图片吧",
            icon: "none",
            mask: !0,
            duration: 1e3
        });
    },
    chooseImage: function() {
        var e = this;
        wx.chooseImage({
            count: 1,
            sourceType: [ "album", "camera" ],
            sizeType: [ "compressed" ],
            success: function(t) {
                console.log(t), t.tempFiles[0].size > 512e3 ? wx.showToast({
                    title: "图片文件过大哦",
                    icon: "none",
                    mask: !0,
                    duration: 1500
                }) : e.setData({
                    img: t.tempFilePaths[0],
                    tempFilePaths: t.tempFilePaths
                });
            }
        });
    },
    onLoad: function() {
        var t = this, a = e.data.openId;
        this.setData({
            openId: a
        }), o.tokenRequest({
            success: function(e) {
                t.setData({
                    token: e.access_token
                });
            }
        });
    },
    preview: function(e) {
        var t = this;
        wx.previewImage({
            urls: [ t.data.img ],
            current: t.data.img
        });
    }
});